package Base.InterFaceTest;


/**
 * 接口的应用：代理模式
 */
public class NetWorkTest {

    public static void main(String[] args) {
        final Server server = new Server();
        final ProxyServer proxyServer = new ProxyServer(server);
        proxyServer.browse();

    }
}

interface Network{
    void browse();

}

// 被代理类
class Server implements Network{

    @Override
    public void browse() {
        System.out.println("真实的服务器访问网络");
    }
}

    // 代理类
class ProxyServer implements Network{

    private final Network network;

    public ProxyServer(Network network){
        this.network = network;
    }

    public void check(){
        System.out.println("联网之前的检查");
    }


        @Override
        public void browse() {
        check();
        network.browse();

        }
    }
